<?php namespace Home\Controller; 
use Think\Controller;

/**
 * Class 会员主页控制器
 * @package Home\Controller
 */
class UController extends CommonController
{
    public function index()
    {
        $id=$_GET['id'];
        $u_sql="select * from user where id='{$id}'";
        $u_res=M('user')->query($u_sql);
        $u_res=current($u_res);
        $this->assign('u_info',$u_res);


        $w_sql="select t2.id as id2,t2.title, t2.create_time as time2, t2.view_num, t2.answer_num,t2.state from user t1 inner join question t2  on t1.id=t2.uid where t1.id='{$id}'";
        $w_res=M()->query($w_sql);        
        $this->assign('w_info',$w_res);


        $a_sql="select t2.id as id3, t2.title as title3, t3.content, t3.create_time as time3 from answer t3 inner join question t2 on t3.qid=t2.id  where t3.uid='{$id}'";
        $a_res=M()->query($a_sql);
        $this->assign('a_info',$a_res);


        $c_sql="select id from answer where uid='{$id}'";
        $c_res=M('answer')->query($c_sql);
        $this->assign('sc',$c_res);
    	$this->display();
    }
}
